package basicQuiz

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'POST'
        url value(consumer("api/v2/assignments/\\d+/answers"),
                producer("api/v2/assignments/1/answers"))
        body("""
            [{   
                "quizId":1,
                "userAnswer":"A"
            }]
            """)
        bodyMatchers {
            jsonPath('$[*].quizId', byRegex(number()))
            jsonPath('$[*].userAnswer', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
            header(id: 2)
            header(userName: 'acey')
        }
    }
    response {
        status 201
    }
}
